package mlz.d_thread;

/*
    匿名内部类方式实现线程
 */
public class InnerDemo {
    public static void main(String[] args) {
        //匿名内部类优化  - 继承Thread
        Thread t1 = new Thread(){
            @Override
            public void run() {
                for (int i = 0; i < 100; i++) {
                    System.out.println(i);
                }
            }
        };
        //启动线程
        t1.start();


        //匿名内部类优化 - 实现Runnable接口
        Runnable r = new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 100; i++) {
                    System.out.println(i);
                }
            }
        };
        //新建线程对象
        Thread t2 = new Thread(r);
        //启动线程
        t2.start();

        //Lambda表达式做优化
    }
}
